package com.imoblife.brainwavestus.user;

import java.util.HashMap;

import com.imoblife.brainwavestus.interfaces.IUserAction;
import com.imoblife.brainwavestus.newdownloadframe.DownLoadTaskInfo;
import com.imoblife.brainwavestus.product.Product;

public class User {
	
	private UserLocalLib mLib;
	private IUserAction mAction;
	private HashMap<String,DownLoadTaskInfo> mDownTask;
	
	public User() {
		
		mLib = new UserLocalLib();
		mDownTask = new HashMap<String,DownLoadTaskInfo>(); 
	}
	
	public void clear() {
		
		if(mLib != null) {
			
			mLib.clear();
		}
	}
	
	public DownLoadTaskInfo getDownTaskByName(String name){
		
		if(mDownTask != null && mDownTask.containsKey(name)) {
			
			return mDownTask.get(name);
		}
		
		return null;
	}
	
	public void addDownTask(DownLoadTaskInfo task) {
		
		if(mDownTask != null) {
			
			mDownTask.put(task.getTaskName(), task);
		}		
	}
	
	public UserLocalLib getLocalLib() {
		
		return mLib;
	}
	
	public void setUserAction(IUserAction action) {
		
		mAction = action;
	}
	
	public boolean act(Product product) {
		
		return mAction.act(product);
	}
}
